package com.haiyou.dc.thread;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Thread.sleep实现倒计时
 */
public class TestSleep {

    public static void main(String[] args) throws InterruptedException {
        Date date = new Date();
        long end = date.getTime();
        while (true) {
            String format = new SimpleDateFormat("mm:ss").format(date);
            System.out.println(format);
            Thread.sleep(1000);
            date = new Date(date.getTime() - 1000);
            if (end - 10000 > date.getTime()) {
                break;
            }
        }
    }
}
